package com.design;

/**
 * @author ytj
 * @date 2023/7/31
 */
public abstract class BaseDoFilter<T> {

    protected BaseDoFilter baseDoFilter;

    public void next(BaseDoFilter baseDoFilter){
        this.baseDoFilter=baseDoFilter;
    }

    public abstract void doFilter(T t);

    public static class Builder<T>{
        private BaseDoFilter<T> head;
        private BaseDoFilter<T> tail;

        public  Builder<T> addBuilder(BaseDoFilter baseDoFilter){
            if(head==null){
                this.head=this.tail=baseDoFilter;
                return this;
            }
            this.tail.next(baseDoFilter);
            this.tail=baseDoFilter;
            return this;
        }

        public BaseDoFilter build(){
            return this.head;
        }
    }
}
